package org.java.assembler;

import java.io.*;

public class BinGenerator {

    private PrintWriter printWriter;
    public BinGenerator(File asmFile) {
        String binFileName = asmFile.getName().replace("asm", "hack");
        File binFile = asmFile.toPath().resolveSibling(binFileName).toFile();
        try {
            printWriter = new PrintWriter(binFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public void write(String bits) {
        printWriter.print(bits);
        printWriter.flush();
    }

    public void close() throws IOException {
        printWriter.close();
    }
}
